package com.ruoyi.web.controller.productManagement;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.StoreProductSummary;
import com.ruoyi.system.service.IStoreProductSummaryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 门店商品汇总 Controller
 *
 * @author ruoyi
 * @date 2025-05-26
 */
@Api(tags="门店商品汇总")
@RestController
@RequestMapping("/system/storeProductSummary")
public class StoreProductSummaryController extends BaseController
{
    @Autowired
    private IStoreProductSummaryService storeProductSummaryService;

    /**
     * 查询门店商品汇总列表
     */
    @ApiOperation("查询门店商品汇总列表")
    @PreAuthorize("@ss.hasPermi('system:summary:list')")
    @GetMapping("/list")
    public TableDataInfo list(StoreProductSummary storeProductSummary)
    {
        startPage();
        List<StoreProductSummary> list = storeProductSummaryService.selectStoreProductSummaryList(storeProductSummary);
        return getDataTable(list);
    }

    /**
     * 导出门店商品汇总列表
     */
    @ApiOperation("导出门店商品汇总列表")
    @PreAuthorize("@ss.hasPermi('system:summary:export')")
    @Log(title = "门店商品汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StoreProductSummary storeProductSummary)
    {
        List<StoreProductSummary> list = storeProductSummaryService.selectStoreProductSummaryList(storeProductSummary);
        ExcelUtil<StoreProductSummary> util = new ExcelUtil<StoreProductSummary>(StoreProductSummary.class);
        util.exportExcel(response, list, "门店商品汇总数据");
    }

    /**
     * 通过id获取门店商品汇总详细信息
     */
    @ApiOperation("通过id获取门店商品汇总详细信息")
    @PreAuthorize("@ss.hasPermi('system:summary:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(storeProductSummaryService.selectStoreProductSummaryById(id));
    }

    /**
     * 新增门店商品汇总
     */
    @ApiOperation("新增门店商品汇总")
    @PreAuthorize("@ss.hasPermi('system:summary:add')")
    @Log(title = "门店商品汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StoreProductSummary storeProductSummary)
    {
        return toAjax(storeProductSummaryService.insertStoreProductSummary(storeProductSummary));
    }

    /**
     * 修改门店商品汇总
     */
    @ApiOperation("修改门店商品汇总")
    @PreAuthorize("@ss.hasPermi('system:summary:edit')")
    @Log(title = "门店商品汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StoreProductSummary storeProductSummary)
    {
        return toAjax(storeProductSummaryService.updateStoreProductSummary(storeProductSummary));
    }

    /**
     * 通过id批量删除门店商品汇总信息
     */
    @ApiOperation("通过id批量删除门店商品汇总信息")
    @PreAuthorize("@ss.hasPermi('system:summary:remove')")
    @Log(title = "门店商品汇总", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(storeProductSummaryService.deleteStoreProductSummaryByIds(ids));
    }
}
